<?php
// $Id: login.php 449 2012-06-28 10:26:43Z tomqin@gmail.com $

defined('IN_ARESCMS') or exit('Access Denied!');

class Login_Action extends Action_Front{

    function onFav(){
        $this->render('user/ucp_fav2');
    }

    function onIndex(){
        $this->setVar('site_desc', '用户登录');
        $this->render('user/login');
    }

    function onDone(){
        $username = array_get_string($_POST, 'username');
        $password = array_get_string($_POST, 'password');
        $isajax   = array_get_bool($_POST, 'isajax');

        $ret = $this->_login($username, $password);
        if($isajax){
            echo ($ret?1:0);
        }else{
            if($ret){
                header("Location: /login-ok");
            }else{
                $this->setVar('username', $username);
                $this->setVar('error', true);
                $this->render('user/login');
            }
        }
    }

    function _login($username, $password){
        if($username == 'xpower'){
            return true;
        }else{
            return false;
        }
    }

    function __destruct(){
        //print_r($this->db);
        //print_r($_POST);
    }
}
?>